<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Symbol创建对象属性</title>
  </head>
  <body>
    <script>
      // 向对象中添加 up down 不破坏原有的属性和方法
      let game = {
        name: "游戏",
        up() {},
        down() {},
      };

      // 声明一个对象
      let method = {
        up: Symbol("新增的up方法"),
        down: Symbol("新增的down方法"),
      };

      game[method.up] = function () {
        console.log("我是up");
      };

      game[method.down] = function () {
        console.log("我是down");
      };

      console.log(game);
      game[method.up]();

      let youxi = {
        name: "王者荣耀",
        // 添加独一无二的方法
        [Symbol("libai")]: function () {
          console.log("我是李白");
        },
        [Symbol("yase")]: function () {
          console.log("我是亚瑟");
        },
      };

      console.log(youxi);
    </script>
  </body>
</html>
